<?php
    $user = $_GET['username'];
    $pass = $_GET['password'];

    $con = mysqli_connect('localhost','root','123456','goodslist');
    $selectSql = "SELECT * FROM `userlist` WHERE `username`='$user'";

    $selectRes = mysqli_query($con,$selectSql);

    $row = mysqli_fetch_assoc($selectRes);

    if($row){ 
        die('用户名已经存在 请重新输入');
    }

    $insertSql = "INSERT INTO `userlist` VALUES(null,'$user','$pass')";
    $insertRes = mysqli_query($con,$insertSql);

    if(!$insertRes){
        die('添加失败');
    }
    $arr = array('code'=>$insertRes,'msg'=>'添加成功');
    print_r(json_encode($arr,JSON_UNESCAPED_UNICODE));
?>